<%@page import="com.jfinal.kit.PropKit"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<title>会员同步</title>
<jsp:include page="../../include/header.jsp"></jsp:include>
<style type="text/css">
table th {
	text-align: center;
}

table td {
	text-align: center;
}

table {
	empty-cells: show;
	border-collapse: collapse;
	margin: 0 auto;
}

.col-lg-9 {
	width: 100%;
}

.pcc {
	width: 110px;
	height: 34px;
}

input {
	text-indent: 10px;
	border-radius: 5px;
}
/*排序 */
.querySort {
	position: relative;
}

.down {
	position: absolute;
	top: 12px;
	display: inline-block;
	width: 10px;
	height: 12px;
	margin-left: 8px;
	background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 61px;
}

.sort .querySort:NTH-OF-TYPE(2) .down {
	top: -3px;
	transform: rotateX(180deg);
}

.querySort:hover .down {
	background: url("${BASE_PATH}/static/images/sprite-arrow.png") 0 21px;
}

.downSort {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 24px;
	opacity: 0;
	cursor: pointer;
}

.upSort {
	position: absolute;
	top: -15px;
	left: 3px;
	width: 18px;
	height: 24px;
	opacity: 0;
	cursor: pointer;
}
</style>
</head>
<body>
	<div id="wrapper" class="row">

		<div class="col-lg-12">
			<h1 class="page-header">会员同步</h1>
		</div>
		<!-- 搜索框 -->
		<div class="title-top col-lg-12">
			<label class="search-label">会员手机号：</label>
				<input type="text" id="sPhone" value="" placeholder="手机号" class="form-control search-input width200" maxlength="21"> 
			<label class="search-label">会员卡号：</label>
				<input type="text" id="sCard" value="" placeholder="请输入会员卡号" class="form-control search-input width200" maxlength="21"> 
			<label class="search-label">匹配状态：</label> 
				<select id="match" class="selectpicker pull-left p-l-5" data-width="12%">
					<option value="0">全部</option>
					<option value="1">已匹配</option>
					<option value="2">未匹配</option>
				</select>
			<button class="btn btn-success search-btn" onclick="query();">确定</button>
			<button class="btn btn-success search-btn" onclick="reset();">重置</button>
			<shiro:hasPermission name="change:sync:doExcel">
				<button onclick="doExcel();" class="btn btn-success pull-right">导出</button>
			</shiro:hasPermission>
			<shiro:hasPermission name="change:sync:toImportExcel">
				<button onclick="toImportExcel();" class="btn btn-success pull-right margin-lr">批量导入</button>
			</shiro:hasPermission>
			
			<div class="clearfix"></div>
		</div>
		<div class="col-lg-12 title-top">
			<div class="col-lg-12">
				<div class="text-muted single-line-text pull-left">
					共 <font color="#428bca" id="dataCount">0</font> 条记录
				</div>
			</div>
			<div class="table-responsive panel panel-default">
				<table id="dataTable" class="table table-hover table-bordered"
					style="overflow: scroll;">
					<thead>
						<tr>
							<th width="150px;">匹配编码</th>
							<th width="150px;">客户名称</th>
							<th width="200px;">会员卡号</th>
							<th width="80px;">会员等级</th>
							<th width="80px;">会员姓名</th>
							<th width="80px;">会员类型</th>
							<th width="180px;">会员证件号</th>
							<th width="100px;">开户银行</th>
							<th width="180px;">银行账号</th>
							<th width="150px;">会员手机号</th>
							<th width="200px;">电子邮箱</th>
							<th width="80px;">营业部</th>
							<th width="120px;">办卡日期</th>
						</tr>
					</thead>
					<tbody id="dataList"></tbody>
				</table>
			</div>
			<div class="col-lg-12">
       			<div class = "pull-right">
        			<div class="text-muted  pull-left" style="margin-top:20px; margin-right:18px;">
						<select id="pageSize" name="pageSize" class="selectpicker" data-width="100" onchange="query()" >
	    					<option value="10" selected = "selected">10条/页</option>
							<option value="15">15条/页</option>
							<option value="20">20条/页</option>
							<option value="50">50条/页</option>
							<option value="100">100条/页</option>
	    				</select>
					</div>
	        		<ul id="dataPagination" class="pagination-sm pull-right"></ul>
	        	</div>
        	</div>
		</div>

	</div>
	<jsp:include page="../../include/javascripts.jsp"></jsp:include>
	<!-- 异步加载下一页数据后，用模板渲染 -->
	<script type="text/html" id="dataTpl">
		{{each list as item}}
				 <tr id="item{{item.id}}" data-id="{{item.id}}">
					<td>{{item.clientCode}}
						{{if !item.clientCode}}未匹配{{/if}}
					</td>
					<td>{{item.phone}}</td>
				 	<td>
						<a href="javascript:showUser('{{item.id}}');"><font color="#40a9ff" id="dataCount">{{if item.card}}{{item.card }}{{/if}}
								{{if !item.card}}--{{/if}}
							</font>
						</a>
					</td>
					<td>{{item.taici | flagTransform:1,'会员',2,'黄金',3,'白金',4,'经纪人',5,'营业部',6,'分公司',7,'公司'}}</td>
					<td>{{item.name}}</td>
					<td>{{item.userType | flagTransform:0,'自然人',1,'法人'}}</td>
					<td>{{if item.cardIdNo}}{{item.cardIdNo}}</td>{{/if}}
						{{if !item.cardIdNo}}--{{/if}}
					<td>{{if item.bankName}}{{item.bankName}}{{/if}}
						{{if !item.bankName}}--{{/if}}
					</td>
					<td>{{item.bankCardNo}}
						{{if !item.bankCardNo}}--{{/if}}
					</td>
					<td>{{item.phone}}</td>
					<td>{{if item.email}}{{item.email}}</td>{{/if}}
						{{if !item.email}}--{{/if}}
					<td>
						{{if item.toBossOneId}}{{item.title}}{{/if}}
						{{if !item.toBossOneId}}--{{/if}}
					</td>
					<td>{{item.createDate }}</td>
				</tr>
		{{/each}}
	</script>
	<script type="text/javascript">
var dataPaginator;
$(query);
function query(){
	var pageSize=$("#pageSize").val();
	 var phone=$("#sPhone").val(),card=$("#sCard").val(),match=$("#match").val();
	 var params = {
		pageSize:pageSize,
		phone:phone,
		card:card,
		match:match
	};
	if(dataPaginator){
		dataPaginator.destroy();
	}
	dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/change/sync/page",params,function(result){
		//设置显示最新的数据数量
		$("#dataCount").html(result.object.totalRow);
		//根据模板渲染数据并填充
		$("#dataList").empty().append(template("dataTpl",result.object));
	});
}
//展示会员详细信息
var showDialog;
function showUser(id){
	showDialog = Kit.dialog("会员详情信息","${BASE_PATH}/change/sync/detail/"+id,{size:'size-wide',closable:true}).open();
}



function reset(){
	$("#sPhone").val("");$("#sCard").val("");
}

function onEditSuccess(newObject){
	$("#item"+newObject.id).replaceWith(template("dataTpl",{"list":[newObject]}));
}
function doExcel(){
	 var phone=$("#sPhone").val(),card=$("#sCard").val(),match=$("#match").val();
	window.location.href="${BASE_PATH}/change/sync/doExcel?phone="+phone+"&card="+card+"&match="+match;
}
//订单量、收藏量、浏览量  单选图片点击切换
var querySort=document.getElementsByClassName("querySort");//点击区域
var down=document.getElementsByClassName("down");
for(var i=0;i<querySort.length;i++){
	   //给每个class添加id标识(当索引)区分每个class
	   querySort[i].id=i;	   
	   //鼠标点击改变背景图片偏移
	   querySort[i].onclick=function(){
		   //当前索引
		   var index=this.id;
		   for( j=0;j<down.length;j++){
			   down[j].style.backgroundPosition="0px 61px";
		   }
		 //改变索引为当前的class背景图片偏移位置
		   down[index].style.backgroundPosition="0px 21px";
	   }
}


function toImportExcel(){
	window.location.href= "${BASE_PATH}/change/sync/toImportExcel";
}

 
</script>
</body>
</html>